// 导入vue-router
import Vue from "vue";
import VueRouter from "vue-router";
import Article from "@/views/Article.vue";
import Collect from "@/views/Collect.vue";
import User from "@/views/User.vue";
import Like from "@/views/Like.vue";
import Detail from "@/views/Detail.vue";
import Layout from "@/views/Layout.vue";
import Login from "@/views/Login.vue";

Vue.use(VueRouter);

// 创建路由对象
const router = new VueRouter({
  // 改类名
  linkActiveClass: "active",
  linkExactActiveClass: "ex-active",
  routes: [
    // 外层切换  父路由 一级路由
    // 将来处理详情页面业务即可
    {
      path: "/login",
      component: Login,
    },
    {
      path: "/detail/:id",
      component: Detail,
    },

    // 将来用于放置 子路由出口  + 4个导航
    {
      path: "/layout",
      component: Layout,
      // 子路由配置
      children: [
        {
          path: "/layout",
          redirect: "/layout/article",
        },
        {
          path: "/layout/article",
          component: Article,
        },
        {
          path: "/layout/collect",
          component: Collect,
        },
        {
          path: "/layout/like",
          component: Like,
        },
        {
          path: "/layout/user",
          component: User,
        },
      ],
    },
  ],
});

export default router;
